from appium import webdriver
import time
import base64

# 连接配置信息
des = {
    "platformName": "Android",
    "platformVersion": "7.1.2",
    "deviceName": "emulator-5554",
    "appPackage": "com.android.settings",
    "appActivity": ".Settings$WifiSettingsActivity"
}
# 初始化驱动对象
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", des)

# # 卸载/移除手机内的app
# driver.remove_app("com.tencent.wework")

# # 安装app
# driver.install_app(r"C:\TT\习知\课件\我的课件\app自动化\WeCom_android_4.0.19.20104_100001.apk")

# # 检查app是否已经安装
# print(driver.is_app_installed("com.tencent.wework"))

# # 发送文件到手机
# str1 = "abcdefg hijklmn"
# # base64编码
# my_data = str(base64.b64encode(str1.encode('gbk')), 'gbk')
# # 将数据发送后至手机
# driver.push_file('/sdcard/my_test0515.txt', my_data)

# # 从手机拉取文件
# my_data = driver.pull_file('/sdcard/my_test0515.txt')
# # base64解码
# str2 = str(base64.b64decode(my_data), "gbk")
# print(str2)

# 获取页面元素结构
print(driver.page_source)

time.sleep(3)
driver.quit()